<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获取p class='demo'>hello JavaScript内部文案</title>
</head>
<body>
    <script>
        var reg = />\S*\s\S*</
        var str = "<p class='demo'>hello JavaScript</p>"
        console.log(str.match(reg)[0].match(/\w+\s\w+/))
    </script>
</body>
</html>